<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-menu default-active='active' mode='horizontal' class='menu-unit'>
          <el-menu-item v-for='item in Container2' :index="'文档'===item.name?'active':'default'">
            <el-link @click="gotoMenu(item.url)" :type="'文档'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
        <table cellpadding="4" cellspacing="0" border="0" width="100%">
          <tr>
            <td class="containerBack">
              <el-menu default-active='active' mode='horizontal' class='menu-unit'>
                <el-menu-item v-for='item in Container3' :index="'企业资质'===item.name?'active':'default'">
                  <el-link @click="gotoMenu(item.url)" :type="'企业资质'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
                </el-menu-item>
              </el-menu>
              <table cellpadding="4" cellspacing="0" border="0" width="100%">
                <tr>
                  <td class="containerBack">
                    <el-form ref="form" :model="s_folder" :rules="rules" label-width="100px" id="mvcfm">
                      <div class="form-unit">
                        <a v-for="dict in s_tree_menu" @click="handleNodeClick(dict)" type='primary'>{{dict.__desc}}></a>
                      </div>
                      <el-button @click="popCustomerNewFolder('')" type='primary' size="mini">新文件夹</el-button>
                      <el-button @click="popCustomerFileUpload('')" type='primary' size="mini">上传文件</el-button>
                      <el-button @click="popCustomerQuotePubFile('')" type='primary' size="mini">引用文件</el-button>
                      <el-button @click="popProductOfficeTecFile('')" type='primary' size="mini">创建文件</el-button>
                      <div class="form-unit">
                        <span class="mvc-title-left"> 文件夹 </span>
                      </div>
                      <el-table :data="s_folder">
                        <el-table-column label="操作" align="center" width='100' type=''>
                          <template slot-scope="scope">
                            <el-dropdown trigger="click">
                              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                              <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item>
                                  <el-link @click="popCustomerUpFolder('&CMIDSEL1='+scope.row.folder_id+'')">修改</el-link>
                                </el-dropdown-item>
                                <el-dropdown-item>
                                  <el-link @click="d_folders('&CMID4='+scope.row.folder_id+'')">删除</el-link>
                                </el-dropdown-item>
                              </el-dropdown-menu>
                            </el-dropdown>
                          </template>
                        </el-table-column>
                        <el-table-column label="文件夹名" prop="folder_id">
                          <template slot-scope="scope">
                            <el-link @click="gotoPage('/crm/sale/CustomerFile?CMID9='+scope.row.folder_id+''+vueparams+'')" type='primary'>{{scope.row.subject}}</el-link>
                          </template>
                        </el-table-column>
                      </el-table>
                      <div class="form-unit">
                        <span class="mvc-title-left"> 文件列表 </span>
                      </div>
                      <el-table :data="s_file">
                        <el-table-column label="操作" align="center" width='100' type=''>
                          <template slot-scope="scope">
                            <el-dropdown trigger="click">
                              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                              <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item>
                                  <el-link @click="popCustomerFileVersionAdd('&CMID4='+scope.row.item_id+'')">增加版本</el-link>
                                </el-dropdown-item>
                                <el-dropdown-item>
                                  <el-link @click="d_files('&CMID4='+scope.row.item_id+'')">删除文件</el-link>
                                </el-dropdown-item>
                                <el-dropdown-item>
                                  <el-link @click="d_link('&CMID4='+scope.row.link_id+'')">删除引用</el-link>
                                </el-dropdown-item>
                              </el-dropdown-menu>
                            </el-dropdown>
                          </template>
                        </el-table-column>
                        <el-table-column label="文件" prop="item_id">
                          <template slot-scope="scope">
                            <el-link @click="gotoPage('/crm/sale/CustomerFileVersion?CMID4='+scope.row.item_id+''+vueparams+'')" type='primary'>{{scope.row.client_filename}}</el-link>
                          </template>
                        </el-table-column>
                        <el-table-column label="类型" prop="subject">
                        </el-table-column>
                        <el-table-column label="尺寸" prop="size">
                        </el-table-column>
                        <el-table-column label="版本" prop="version">
                        </el-table-column>
                        <el-table-column label="修改日期" prop="modified">
                        </el-table-column>
                      </el-table>
                    </el-form>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'文档'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="CustomerNewFolderVisible" append-to-body>
      <CustomerNewFolder v-if="CustomerNewFolderVisible" ref="CustomerNewFolder" :popparams="popparams"> </CustomerNewFolder>
    </el-dialog>
    <el-dialog :visible.sync="CustomerFileUploadVisible" append-to-body>
      <CustomerFileUpload v-if="CustomerFileUploadVisible" ref="CustomerFileUpload" :popparams="popparams"> </CustomerFileUpload>
    </el-dialog>
    <el-dialog :visible.sync="CustomerQuotePubFileVisible" append-to-body>
      <CustomerQuotePubFile v-if="CustomerQuotePubFileVisible" ref="CustomerQuotePubFile" :popparams="popparams"> </CustomerQuotePubFile>
    </el-dialog>
    <el-dialog :visible.sync="ProductOfficeTecFileVisible" append-to-body>
      <ProductOfficeTecFile v-if="ProductOfficeTecFileVisible" ref="ProductOfficeTecFile" :popparams="popparams"> </ProductOfficeTecFile>
    </el-dialog>
    <el-dialog :visible.sync="CustomerUpFolderVisible" append-to-body>
      <CustomerUpFolder v-if="CustomerUpFolderVisible" ref="CustomerUpFolder" :popparams="popparams"> </CustomerUpFolder>
    </el-dialog>
    <el-dialog :visible.sync="CustomerFileVersionAddVisible" append-to-body>
      <CustomerFileVersionAdd v-if="CustomerFileVersionAddVisible" ref="CustomerFileVersionAdd" :popparams="popparams"> </CustomerFileVersionAdd>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import CustomerNewFolder from "@/views/crm/sale/CustomerNewFolder";
  import CustomerFileUpload from "@/views/crm/sale/CustomerFileUpload";
  import CustomerQuotePubFile from "@/views/crm/sale/CustomerQuotePubFile";
  import ProductOfficeTecFile from "@/views/crm/product/ProductOfficeTecFile";
  import CustomerUpFolder from "@/views/crm/sale/CustomerUpFolder";
  import CustomerFileVersionAdd from "@/views/crm/sale/CustomerFileVersionAdd";
  export default {
    name: 'ContactsArchives',
    components: {
      CustomerNewFolder,
      CustomerFileUpload,
      CustomerQuotePubFile,
      ProductOfficeTecFile,
      CustomerUpFolder,
      CustomerFileVersionAdd,
    },
    props: ['popparams'],
    data() {
      return {
        CustomerNewFolderVisible: false,
        CustomerNewFolderValue: null,
        CustomerNewFolderDesc: null,
        CustomerFileUploadVisible: false,
        CustomerFileUploadValue: null,
        CustomerFileUploadDesc: null,
        CustomerQuotePubFileVisible: false,
        CustomerQuotePubFileValue: null,
        CustomerQuotePubFileDesc: null,
        ProductOfficeTecFileVisible: false,
        ProductOfficeTecFileValue: null,
        ProductOfficeTecFileDesc: null,
        CustomerUpFolderVisible: false,
        CustomerUpFolderValue: null,
        CustomerUpFolderDesc: null,
        CustomerFileVersionAddVisible: false,
        CustomerFileVersionAddValue: null,
        CustomerFileVersionAddDesc: null,
        vueparams: this.getVUEParams(""),
        s_folder: [],
        s_file: [],
        s_tree_menu: [],
        loading: false,
        Container: null,
        Container2: null,
        Container3: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "文档"
      }, 'Container', this.vueparams);
      this.loadContainerMenu({
        pid: "14ED91704E794C43A973E8BEFF724C15",
        name: "客户联系人右菜单",
        selected: "文档"
      }, 'Container2', this.vueparams);
      this.loadContainerMenu({
        pid: "14ED91704E794C43A973E8BEFF724C15",
        name: "文档页面菜单",
        selected: "企业资质"
      }, 'Container3', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/CustomerContacts/contactsArchives?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_folders(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerContacts/d_folders?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_files(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerContacts/d_files?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_link(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/crm/sale/CustomerContacts/d_link?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popCustomerNewFolder(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.CustomerNewFolderVisible = !this.CustomerNewFolderVisible;
      },
      popCustomerFileUpload(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.CustomerFileUploadVisible = !this.CustomerFileUploadVisible;
      },
      popCustomerQuotePubFile(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.CustomerQuotePubFileVisible = !this.CustomerQuotePubFileVisible;
      },
      popProductOfficeTecFile(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ProductOfficeTecFileVisible = !this.ProductOfficeTecFileVisible;
      },
      popCustomerUpFolder(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.CustomerUpFolderVisible = !this.CustomerUpFolderVisible;
      },
      popCustomerFileVersionAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.CustomerFileVersionAddVisible = !this.CustomerFileVersionAddVisible;
      },
      handleOutline(data) {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/CustomerContacts/s_tree_menu?' + this.vueparams,
        }).then(data => {
          this.s_tree_menu = data.s_tree_menu;
          this.s_tree_menu = this.s_tree_menu.reverse();
        })
      },
    },
  }
</script>
